/**
 * @see https://umijs.org/docs/max/access#access
 * */
export default function access(
  initialState: { currentUser?: API.CurrentUser } | undefined
) {
  const { currentUser } = initialState ?? {}
  return {
    canAdmin: currentUser && currentUser.access === "管理员",
    canUser: currentUser, // 只要登录了就可以
    canServiceman:
      currentUser &&
      (currentUser.access === "管理员" || currentUser.access === "维护人员")
  }
}
